﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WeatherTest.Base;

namespace WeatherTest
{
    public class StatisticsDisplay : IObserver, IDisplayElement
    {
        private static float _min, _max, _averge;
        float[] a = { _min, _max, _averge };
        public void Display()
        {
            //throw new NotImplementedException();
            Console.WriteLine($"当前最大值为{_max},最小值为{_min}，平均值为{_averge}");
        }

        public void Update(float temp, float humidity, float pressure)
        {

            float averge = (temp + humidity) / 2;
            _averge = averge;

            float[] a = { temp, humidity, pressure };
            Array.Sort(a);
            _max = a[2];
            _min = a[0];

            //float a;
            //a = temp;
            //temp = humidity;
            //humidity = pressure;
            //pressure = a;
            //_max = temp;
            //_min = a;

            Display();
            //throw new NotImplementedException();
        }
    }
}
